<style type="text/css">
    #hr-executeSchedule-update {
        padding: 20px 25px 25px 0;
    }
</style>

<!-- 注意id属性每个页面id必须独立-->
<div class="layui-fluid" id="hr-executeSchedule-update">
    <!-- 注意lay-filter属性，该属性为form表单唯一属性-->
    <form class="layui-form" action="" lay-filter="hr-executeSchedule-update-form">
        <div class="layui-form-item">
            <!-- 隐藏当前对象id-->
            <div class="layui-form-item" >
                <label class="layui-form-label">序号</label>
                <div class="layui-input-block">
                    <input  class="layui-input" type="text" name="id" data-th-value="${executeSchedule.id}" disabled style="background-color: #afb3bf">
                </div>
            </div>
            <div class="layui-form-item febs-hide" >
                <label class="layui-form-label">TrainningPlanExecuteId</label>
                <div class="layui-input-block">
                    <input  class="layui-input" type="text" name="trainningPlanExecuteId">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label febs-form-item-require">调整时间</label>
                <div class="layui-input-block">
                    <input  class="layui-input" type="text" name="planDate" id="hr-executeSchedule-planDate-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label febs-form-item-require">讲师信息</label>
                <div class="layui-input-block">
                    <input name="teacherInfo" class="layui-input repetitive"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label febs-form-item-require">备注</label>
                <div class="layui-input-block">
                <textarea  name="remark" class="layui-textarea repetitive" placeholder="请记录调整执行计划的原因"/>
                </div>
            </div>
            <div class="layui-form-item febs-hide">
                <button class="layui-btn" lay-submit="" lay-filter="executeSchedule-update-form-submit"
                        id="hr-executeSchedule-update-submit-btn"></button>
            </div>
        </div>
    </form>
</div>

<script data-th-inline="javascript">
    layui.use(['febs', 'form', 'validate', 'laydate'], function () {
        let $ = layui.$,
            laydate = layui.laydate,
            febs = layui.febs,
            layer = layui.layer,
            form = layui.form,
            // 获得后台出入的实体对象
            executeSchedule = [[${executeSchedule}]],
            // 验证
            validate = layui.validate;
        // 表单验证
        form.verify(validate);
        // 表单渲染
        form.render();
        // 初始化页面数据
        initTagValue();

        //加载日期组件
        laydate.render({
            elem: '#hr-executeSchedule-planDate-input',
            range: false,
            trigger: 'click'
        });
        // 初始化页面数据
        function initTagValue() {
            form.val("hr-executeSchedule-update-form", {
                "id": executeSchedule.id,
                "planDate": executeSchedule.planDate,
                "lastModifyUserName": executeSchedule.lastModifyUserName,
                "teacherInfo": executeSchedule.teacherInfo,
                "trainningPlanExecuteId": executeSchedule.trainningPlanExecuteId
            });
        }
        // 表单提交事件
        form.on('submit(executeSchedule-update-form-submit)', function (data) {
            console.log("进入修改" + data.field)
            // 如果都没有修改直接返回
            if (febs.nativeEqual(data.field, executeSchedule)) {
                febs.alert.warn('数据未作任何修改！');
                return false;
                // 如果只修改了名字之外的东西，则直接更新
            }else if(!febs.nativeEqual(data.field.planDate, executeSchedule.planDate)
                | !febs.nativeEqual(data.field.teacherInfo, executeSchedule.teacherInfo)){
                febs.post(ctx + 'executeSchedule/update', data.field, function (resp) {
                    if(resp.status = 200){
                        layer.closeAll();
                        febs.alert.success('计划数据修改成功');
                        // 点击父页面查询按钮
                        $('#hr-executeSchedule').find('#hr-executeSchedule-query-btn').click();
                    }else {
                        febs.alert.fail('数据修改失败!!');
                    }

                });
            }
            return false;
        });
    });
</script>